<template>
  <div>
    <el-container v-if="!notShowMenu">
      <el-aside width="200px" style="overflow-y: auto;height: 100vh">
        <el-tree :data="router" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
      </el-aside>
      <el-main style="overflow-y: auto;height: 100vh">
        <router-view />
      </el-main>
    </el-container>
    <router-view v-else/>
   </div>
</template>

<script>
import router, {routes} from "@/router/index.js";
import {getQueryObject} from "@localModules/ZhiXinLib/utils";

export default {
  name: 'App',
  computed:{
    router() {
      return routes.map(i=>{
        return {
          url: i.path || '/',
          title: i.meta.title
        }
      })
    },
    notShowMenu() {
      const queryObject = getQueryObject();
      return this.$route.meta?.notShowMenu === true || queryObject.hasOwnProperty('isChildrenWindow')
    }
  },
  data(){
    return {
      defaultProps:{
        children: 'children',
        label: 'title'
      }
    }
  },
  methods: {
    handleNodeClick(data){
      this.$router.push({
        path: data.url
      })
    }
  }
}
</script>
<style lang="scss">
*{
  margin: 0;
  padding: 0;
}
</style>
